package moon.core.entity;

import moon.core.Name;
import moon.core.classdef.ClassDef;
import moon.core.classdef.MethDec;
import moon.core.classdef.Type;

/** 
 * 
 * It represents the returned entity by a function.
 * All function must have one result (as minimum and maximum).
 * 
 * @author <a href="mailto:rmartico@ubu.es">Ra&uacute;l Marticorena</a>
 * @since JavaMoon-1.3
 * 
 */
@SuppressWarnings("serial")
public abstract class Result extends PredefinedEntity {
	
	/**
	 * Constructor.
	 * 
	 * @param name name
	 * @param type type
	 * @param functionDec function
	 */
	public Result(Name name, Type type, FunctionDec functionDec) {
		super(name, type);
		this.setFunctionDec(functionDec);
	}
	
	/**
	 * Function where is used the result.
	 * 
	 */
	private FunctionDec functionDec;   

    
    /**
     * Gets the function where is returned the result.
     * 
     * @return function
     * @see #setFunctionDec
     */
    public FunctionDec getFunctionDec(){
    	return this.functionDec;    	
    }
   
    /**
     * Sets the function where the entity is used.
     * 
     * @param functionDec function
     * @see #getFunctionDec
     */
    public void setFunctionDec(FunctionDec functionDec){
    	this.functionDec = functionDec;
    }

    /**
	 * {@inheritDoc}.
	 * 
	 * @return {@inheritDoc}
     */
    @Override
    public Name getName(){
		return this.functionDec.getName();    	
    }

    /**
     * {@inheritDoc}.
     * 
     * @return {@inheritDoc}
     */
	@Override
	public Name getUniqueName() {
		return this.functionDec.getUniqueName();
	}
	
	/**
	 * {@inheritDoc}.
	 * 
	 * @return {@inheritDoc}
	 */
	@Override
	public ClassDef getClassDef() {
		return this.functionDec.getClassDef();
	}
} // Result
